#![no_main]
use libfuzzer_sys::fuzz_target;
use libfuzzer_sys::arbitrary::{Arbitrary, Unstructured, Result};
use smallvec::SmallVec;

#[derive(Debug)]
enum MyVecOp {
    Push {
        // The size of allocation to make.
        n: u8,
    },
    Grow {
        // Free the index^th allocation we've made.
        n: u8
    },
    Pop {
        n: u8,
    },
}

// let mut v: SmallVec<[u8; 2]> = SmallVec::new();
// v.push(0);
// v.push(1);
// v.push(2); // now capacity is 4
// println!("capacity: {}, inline size: {}", v.capacity(), v.inline_size());
// // grow with the same capacity
// v.grow(4);
// // The backing storage is now freed, here be dragons.
// println!("{:?}", v);
// https://docs.google.com/document/d/1qsNkMLH9nT-qncM16xNj5VMJjHkSyxB8wK9nk4RCiOs/edit
pub fn smallvec2_t_2019_0009(data:&[u8]) {
    // Wrap that raw data in an `Unstructured`.
    // let mut unstructured = Unstructured::new(data);
    // let mut v: SmallVec<[u8; 2]> = SmallVec::new();
    // // Generate an arbitrary instance of `MyType` and do stuff with it.
    // if let Ok(value) = OpList::arbitrary(&mut unstructured) {
    //     for op in OpList {
    //         match op {
    //             MyVecOp::Push { n } => {
    //                 while n >= 0 {
    //                     v.push(n..into());
    //                     n -= 1;
    //                 } 
    //             }
    //             MyVecOp::Pop { n } => {
    //                 while n >= 0 {
    //                     v.pop();
    //                     n -= 1;
    //                 } 
    //             }
    //             MyVecOp::Grow { n } => {
    //                 v.grow(n.into());
    //             }
    //         }
    //         println!("{:?}", v);
    //     }
    // }
}

// fuzz_target!(|oplist: Vec<MyVecOp>| {
//     // fuzzed code goes here
   
// });
fuzz_target!(|data: &[u8]| {
    // fuzzed code goes here
    if let Ok(s) = std::str::from_utf8(data) {
        let _ = guess::guess_str(s);
    }
});
